import Mock from "mockjs";
import qs from "qs";

// 提交评论
Mock.mock("/api/message", "post", {
    code: 0,
    msg: "",
    data: {
        id: "@guid",
        nickname: "@ctitle",
        content: "@csentence(20, 30)",
        createDate: Date.now(),
        avatar: "@image(250x250, @color, #fff, hello)",
    }
})


// // 获取评论
Mock.mock(/^\/api\/message\/?(\?.+)?$/, "get", function (option) {
    const query = qs.parse(option.url)
    return Mock.mock({
        code: 0,
        msg: "",
        data: {
            "total": 6,
            "rows": [
                {
                    "nickname": "新年快乐",
                    "content": "万事胜意",
                    "createDate": 1661696710945,
                    "avatar": "https://lgy-assets.oss-cn-shanghai.aliyuncs.com/my-img/avatar/ohmygood.gif",
                    "id": "630b7ac6f3dfa036d520a0e4"
                },
                {
                    "nickname": "peng",
                    "content": "666666",
                    "createDate": 1660555474764,
                    "avatar": "https://lgy-assets.oss-cn-shanghai.aliyuncs.com/my-img/avatar/happy.gif",
                    "id": "62fa10d2ec878f36d4310c21"
                },
                {
                    "nickname": "Null",
                    "content": "牛牛牛",
                    "createDate": 1660555458772,
                    "avatar": "https://lgy-assets.oss-cn-shanghai.aliyuncs.com/my-img/avatar/666.png",
                    "id": "62fa10c2ec878f36d4310c1d"
                },
                {
                    "nickname": "old six",
                    "content": "66",
                    "createDate": 1660539160199,
                    "avatar": "https://lgy-assets.oss-cn-shanghai.aliyuncs.com/my-img/avatar/happy.gif",
                    "id": "62f9d118f3dfa036d5209ee5"
                },
                {
                    "nickname": "喜",
                    "content": "牛",
                    "createDate": 1660539155046,
                    "avatar": "https://lgy-assets.oss-cn-shanghai.aliyuncs.com/my-img/avatar/scare.gif",
                    "id": "62f9d113f3dfa036d5209ee0"
                },
                {
                    "nickname": "哈喽",
                    "content": "123",
                    "createDate": 1660532072460,
                    "avatar": "https://lgy-assets.oss-cn-shanghai.aliyuncs.com/my-img/avatar/looklook.png",
                    "id": "62f9b568ec878f36d4310b0a"
                }
            ]
        }
    })
})